package sjtu.ist.warehouse4ws.action;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import sjtu.ist.warehouse4ws.tool.XmlFileToString;

import com.opensymphony.xwork2.ActionSupport;

public class ShowXmlContentAction extends ActionSupport{
private XmlFileToString xmlString;
private String xmlContent;
public String getXmlContent() {
	return xmlContent;
}

public void setXmlContent(String xmlContent) {
	this.xmlContent = xmlContent;
}

public void setXmlString(XmlFileToString xmlString) {
	this.xmlString = xmlString;
}
//XML内容进行分文件读取
public String showXmlContent(){
	HttpServletRequest request = ServletActionContext.getRequest ();
	String xmlName=request.getParameter("xmlName");
	String pathName=request.getParameter("pathName");
	String basepath=ServletActionContext.getServletContext().getRealPath("/upload/files/").replaceAll("\\\\", "/")+"/";
	basepath=basepath+pathName+"/";
//	System.out.print(basepath);
	String path=basepath+xmlName;
	
	try {
		xmlContent=xmlString.readXmlFile(path);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return SUCCESS;
}



}
